<script setup lang="ts">

import { ref } from 'vue'
import { useLogin } from '../../../pinia/loginInfo'
import router from '../../../router';

const store = useLogin()
const activeIndex = ref('1')
const activeIndex2 = ref('1')
const handleSelect = (key: string, keyPath: string[]) => {
    console.log(key, keyPath)
}

const handleClick = () => {
    // eslint-disable-next-line no-alert
    //alert('button click')
    if (store.token == '') {
        router.push('/login')
    }
}

</script>

<template>
    <el-row :gutter="20">
        <el-col :span="4">
            <div class="grid-content ep-bg-purple">图标</div>
        </el-col>
        <el-col :span="20">
            <div class="grid-content ep-bg-purple">
                <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" :ellipsis="false"
                    @select="handleSelect">
                    <el-menu-item index="1">Processing Center</el-menu-item>
                    <el-sub-menu index="2">
                        <template #title>Workspace</template>
                        <el-menu-item index="2-1">item one</el-menu-item>
                        <el-menu-item index="2-2">item two</el-menu-item>
                        <el-menu-item index="2-3">item three</el-menu-item>
                        <el-sub-menu index="2-4">
                            <template #title>item four</template>
                            <el-menu-item index="2-4-1">item one</el-menu-item>
                            <el-menu-item index="2-4-2">item two</el-menu-item>
                            <el-menu-item index="2-4-3">item three</el-menu-item>
                        </el-sub-menu>
                    </el-sub-menu>
                    <el-menu-item index="3" disabled>Info</el-menu-item>
                    <el-menu-item index="4">Orders</el-menu-item>

                    <!--头像的地方-->
                    <div class="flex-grow" />
                    <div class="demo-type">
                        <div>
                            <el-button @click="handleClick" circle link>
                                <el-dropdown>
                                    <el-avatar :size="50"> {{ store.token == '' ? '登录' : store.token }} </el-avatar>
                                    <template v-if="store.token != ''" #dropdown>
                                        <el-dropdown-menu>
                                            <el-dropdown-item>Action 1</el-dropdown-item>
                                            <el-dropdown-item>Action 2</el-dropdown-item>
                                            <el-dropdown-item>Action 3</el-dropdown-item>
                                            <el-dropdown-item>Action 4</el-dropdown-item>
                                            <el-dropdown-item>Action 5</el-dropdown-item>
                                        </el-dropdown-menu>
                                    </template>
                                </el-dropdown>
                            </el-button>
                        </div>
                    </div>
                </el-menu>
            </div>
        </el-col>
    </el-row>
</template>



<style scoped>
.el-row {
    margin-bottom: 20px;
}

.el-row:last-child {
    margin-bottom: 0;
}

.el-col {
    border-radius: 4px;
}

.grid-content {
    border-radius: 4px;
    min-height: 36px;
    /* padding-left: 0px; */
}

.flex-grow {
    flex-grow: 1;
}
</style>